home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_09
/
9n09024b
< prev
next >
Wrap
Text File
|
1991-07-10
|
612b
|
29 lines
/* --------------------------------------------------------------
FUNCTION GET_FREE_NODE: The steps to get a node from the free node list
are:
A. If the free node list is empty, get memory for a new node and
return its address.
B. Else remove the first node from the free list and use that.
-------------------------------------------------------------- */
Node *get_free_node(void)
{
Node *pnew_node;
/*A*/ if (pfree_node == NULL) {
pnew_node = malloc(sizeof(Node));
}
/*B*/ else {
pnew_node = pfree_node;
pfree_node = pfree_node->pfwd;
}
return pnew_node;
}